% $Header: /cvsroot/html2ps/postscript/flow.box.ps,v 1.1 2005/12/18 07:21:38 Konstantin Exp $

/flow-box {                        % => Child Parent
  exch                            % => Parent Child

% in case we're working with floated box,
% set 'display' property to 'block' value (FIXME: make this more compatible with CSS spec. 9.7)
  dup get-box-dict /Float get
  /none ne {
% if line box already have content, the flow this float _after_ the line box
% otherwise flow it immediately.
    1 index get-line length 0 gt {
      1 index exch add-deferred-float
      pop
    } {
      flow-float                   % => Parent
% Fix parent's current-x value
% in case this float had 'float: left' style first inline box should be shifted to the right
      offset-x-floats              % => 
    } ifelse
  } {
    dup get-flow-fun
    exec
  } ifelse
} def

/apply-clear {                     % => Box Y
  1 index get-box-dict /Clear get
  dup /left eq exch /both eq
  or {
    {
      dup get-box-dict /Float get /left eq {
        get-bottom min
      } {
        pop
      } ifelse
    } 1 index context-floats reduce          % => Parent Child DY FY1
    min
  } if

  1 index get-box-dict /Clear get
  dup /right eq exch /both eq
  or {
    {
      dup get-box-dict /Float get /right eq {
        get-bottom min
      } {
        pop
      } ifelse
    } 1 index context-floats reduce          % => Parent Child DY FY1 
    min
  } if
} def